package fr.teuteuf.runstickmanrun.map.block;

import com.badlogic.gdx.physics.box2d.World;

import fr.teuteuf.runstickmanrun.map.MapGenerator;
import fr.teuteuf.runstickmanrun.map.tile.DamagingBoxTile;
import fr.teuteuf.runstickmanrun.map.tile.DamagingSolidBoxTile;
import fr.teuteuf.runstickmanrun.map.tile.SolidBoxTile;
import fr.teuteuf.runstickmanrun.map.tile.Tile;

public abstract class AbstractMapBlock {
	
	private int minDifficultyLevel, medDifficultyLevel, maxDifficultyLevel;
	private int currentLevel;
	
	public abstract int generateBlock(World world, MapGenerator mg, int nbHorizontalTiles);
	
	protected void buildBlockColumn(int damage, byte borders, int x, int y1, int y2, int textureX, int textureY, World world, MapGenerator mg) {
		if(y2 < y1) {
			int tempY = y2;
			y2 = y1;
			y1 = tempY;
		}
		
		for(; y1 <= y2; y1++) {
			if(borders != 0 && damage == 0) {
				mg.addTile(new SolidBoxTile(borders, textureX, textureY, x * Tile.TILE_SIZE, y1 * Tile.TILE_SIZE, world));
			} else if(borders != 0 && damage != 0) {
				mg.addTile(new DamagingSolidBoxTile(borders, textureX, textureY, x * Tile.TILE_SIZE, y1 * Tile.TILE_SIZE, world, damage));
			} else if(borders == 0 && damage == 0) {
				mg.addTile(new Tile(textureX, textureY, x * Tile.TILE_SIZE, y1 * Tile.TILE_SIZE));
			} else if(borders == 0 && damage != 0) {
				mg.addTile(new DamagingBoxTile(textureX, textureY, x * Tile.TILE_SIZE, y1 * Tile.TILE_SIZE, world, damage));
			}
		}
	}
	
	public void setDifficulties(int min, int med, int max) {
		minDifficultyLevel = min;
		medDifficultyLevel = med;
		maxDifficultyLevel = max;
	}

	public int getMinDifficultyLevel() {
		return minDifficultyLevel;
	}

	public int getMedDifficultyLevel() {
		return medDifficultyLevel;
	}

	public int getMaxDifficultyLevel() {
		return maxDifficultyLevel;
	}

	public int getCurrentLevel() {
		return currentLevel;
	}

	public void setCurrentLevel(int currentLevel) {
		this.currentLevel = currentLevel;
	}
}
